<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" onclick="addGrade(<?php echo $edu_id; ?>);" value="新增" style="margin-right:30px;" class="fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        	<input type="button" value="删除" onclick="delete_all()"  class="fl b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                    	<th width="40" align="right" class="m_hr_t m_hr_b pr10"><input type="checkbox" class="checkboxs"></th>
                        <th width="115" align="center" class="m_hr_t m_hr_b">年级代码</th>
                        <th width="175" align="center" class="m_hr_t m_hr_b">年级名称</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">是否生效</th>
                        <th width="300" align="center" class="m_hr_t m_hr_b">备注</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php if (!empty($data)): ?>
                        <?php foreach ($data as $value): ?>
                            <tr>
                            	<td align="right" class="m_hr_b pr10"><input type="checkbox" name="deleteAll[]"  value="<?php echo $value['grade_id'];?>" class="checkbox"></td>
                                <td align="center" class="m_hr_b"><?php echo $value['grade_code']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $value['grade_name']; ?></td>

                                <?php if ($value['disabled'] == 1): ?>
                                    <td align="center" class="m_hr_b">
                                        <input type="checkbox" disabled='' checked="checked" />
                                    </td>
                                <?php else: ?>
                                    <td align="center" class="m_hr_b">
                                        <input type="checkbox" disabled='' />
                                    </td>
                                <?php endif; ?>				
                                <td align="center" class="m_hr_b" title="<?php echo $value['description'];?>"><?php echo (!empty($value['description'])) ? Func::get_word($value['description'], 25) : $value['description']; ?></td>				
                                <td align="center" class="m_hr_b">
                                    <img src="/themes/default/images/Sipei/edit.png" title="编辑" class="mr10 cursor" onclick="updateGradeInfo(<?php echo $value['grade_id']; ?>)" />
                                    <img src="/themes/default/images/Sipei/delate.png" title="删除" class="cursor" onclick="set_ok(<?php echo $value['grade_id']; ?>)" />
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="5"><h1 align="center">暂无数据</h1></td>              
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>
</div>
<script>
                function set_ok(grade_id) {
               
                    $.dialog.confirm('确定删除吗', function() {
                        $.get('/school/default/delete_g_all', {grade_id: grade_id}, function(data) {
                			location.reload();
                		   
                		});
                    });
                }

                function delete_all(){
                	var aa='';
                	$("input[name='deleteAll[]']:checkbox:checked").each(function(){
						aa+=$(this).val()+',';
					});
					if(aa == ''){
						$.dialog.alert("请选择要删除条目");
						return false;
					}
					$.dialog.confirm('确定删除所选数据吗', function() {

						aa+=0;
                		$.get('/school/default/delete_g_all', {grade_id: aa}, function(data) {
                			location.reload();
                		   
                		});
                	});
                }
                
                function updateGradeInfo(grade_id) {
                    if (grade_id != '') {
                        api = $.dialog({
                            id: 'testID2',
                            lock: true,
                            padding: 0,
                            fixed: true,
                            title: "编辑",
                            width: 480,
                            height: 430,
                            max: false,
                            min: false
                        });
                        $.get('/school/default/update_grade', {grade_id: grade_id,time:new Date(), edu_id: "<?php echo $edu_id; ?>"}, function(html) {
                            api.content(html);
                        });
                    }
                }

                function addGrade(id) {
                    api = $.dialog({
                        id: 'testID2',
                        lock: true,
                        padding: 0,
                        fixed: true,
                        title: "新增",
                        width: 480,
                        height: 430,
                        max: false,
                        min: false
                    });
                    $.get('/school/default/add_grade', {edu_id: id}, function(html) {
                        api.content(html);
                    });
                }
								$(function() {
                    $(".checkboxs").click(function() {
                        var checkedS = $(this).attr("checked");
                        if (checkedS) {
                            $(".checkbox").attr("checked", true)
                        } else {
                            $(".checkbox").removeAttr("checked")
                        }
                    })

                })

</script>